package basic.courseLearn03.sort;

import basic.courseLearn01.utils.FunctionSort;
import basic.courseLearn01.utils.SortUtils;
import basic.courseLearn03.heap.RelateOperate;
import org.junit.Test;

public class HeapSort implements FunctionSort {
    @Override
    public int[] sort(int[] result) {

        return heapSort(result);
    }

    @Test
    public void test(){
//        int[] arr = new int[]{61, 43, 15, 15, 19, -57, 5, -73, 4, -18};
//        arr=heapSort(arr);
//        System.out.println(CommonUtil.printArray(arr));
        SortUtils.executeCheckAlgorithm(1_0000,1000,1000,this);
    }

    public static int[] heapSort(int[] arr){
        arr=RelateOperate.initHeap_one(arr);
        for (int i = 0; i < arr.length; i++) {
            arr[arr.length-i-1]=RelateOperate.push(arr);
        }
        return arr;
    }
}
